package com.lovcreate.shop.mgt.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 文件名：WebUtil.java
 * 创建人：lvjx
 * 创建日期: 2016-12-22 13:59
 * 描  述：
 * 版本号：1.0
 */

public class WebUtil {

    /**
     * 获取当前HttpServletRequest对象
     * @return
     */
    public static HttpServletRequest getHttpServletRequest(){
        ServletRequestAttributes sra= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if(sra==null){
            return null;
        }else{
            return sra.getRequest();
        }
    }

}
